﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ResultUC
{
    /// <summary>
    /// Test history user control
    /// </summary>
    /// <remarks>trungpv@vnext.vn</remarks>
    public partial class History : UserControl
    {
        #region Attributs and Getter/Setter
        #endregion
        public History()
        {
            InitializeComponent();
        }

        private void History_Load(object sender, EventArgs e)
        {
            lvTestHistory.Columns[0].Width = lvTestHistory.Width * 55 / 100;
            lvTestHistory.Columns[1].Width = lvTestHistory.Width * 15 / 100;
            lvTestHistory.Columns[2].Width = lvTestHistory.Width * 23 / 100;
        }

        /// <summary>
        /// Update list view from result information
        /// </summary>
        /// <param name="isOK"></param>
        /// <param name="time"></param>
        /// <param name="filePath"></param>
        public void updateHistory(bool isOK, double time, string filePath)
        {
            ListViewItem item = new ListViewItem(System.IO.Path.GetFileNameWithoutExtension(filePath) 
                + ".bmp");
            if (isOK)
            {
                item.ForeColor = System.Drawing.Color.Green;
                item.SubItems.Add("OK");
            }
            else
            {
                item.ForeColor = System.Drawing.Color.Red;
                item.SubItems.Add("NG");
            }
            item.SubItems.Add(time.ToString("####0.00"));
            lvTestHistory.Items.Insert(0, item);
        }
    }
}
